﻿using SQLitePCL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZDevice.Event;

namespace ZZMES.Data
{
    public  class DataProviderService
    {
        private readonly SqliteDBContext dBContext;
        private readonly IEventAggregator eventAggregator;
        public List<CommunicateConfig> communicateConfigs { get; set; }

        public DataProviderService(SqliteDBContext dBContext, IEventAggregator eventAggregator)
        {
            this.dBContext = dBContext;
            this.eventAggregator = eventAggregator;
            Batteries.Init();
            dBContext.Database.EnsureCreated();
            communicateConfigs = dBContext.SystemParams.ToList();
        }

        public void SaveIPConfigs() 
        {
            dBContext.SystemParams.UpdateRange(communicateConfigs);
            dBContext.SaveChanges();
        }

    }
}
